﻿using System;
using System.Collections.Generic;
using System.Text;
using SchEdu.Framework.Algorithm;
using SchEdu.Framework.Algorithm.Rules;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Validators;

namespace FAM_DR
{
    class FAM_MSAlgorithm : FAM
    {
        protected override SchEduDataSet.OperationRow ApplyDispatchRule(int t, SchEduDataSet.MachineRow machine, OperationList operations)
        {
            int minSlack = Int32.MaxValue;
            SchEduDataSet.OperationRow nextOperation = null;
            foreach (SchEduDataSet.OperationRow op in operations)
            {
                int slack = op.OrderRow.DueDate - OrderOperationSortedList[op.OrderRow].GetProcessingTime();
                if (slack < minSlack)
                {
                    nextOperation = op;
                    minSlack = slack;
                }
            }

            return nextOperation;
        }

        public override AboutInfo AboutInfo
        {
            get
            {
                AboutInfo aboutInfo = new AboutInfo();
                aboutInfo.Title = "FAM MS";
                aboutInfo.Description = Resources.FAM_MSAlgorithmDescription;
                aboutInfo.Guid = new Guid("{C8AE55A1-A159-4af9-9F43-93BB381CC540}");
                return aboutInfo;
            }
        }
    }
}
